<?php 

function render_status($status, $html) {
	switch ($status) {
		case 'red': 
			return $html->image('redlight_yb.jpg', array('alt' => 'No Submission'));
			break;
		case 'yellow':
			return $html->image('yellowlight_yb.jpg', array('alt' => 'Incomplete'));
			break;
		case 'green':
			return $html->image('greenlight_yb.jpg', array('alt' => 'Complete'));
			break;
	}
}

?>
<h3>Upload Scanned Reference documents</h3>
<?php echo $this->Form->create('Reference', array('type' => 'file', 
							'url' => array('action'=> 'adminComplete', $this->data['Application']['id']))); ?>
<p>
	Use this page to upload Letter of Recommendation documents for applicant; <?php echo $this->data['Application']['firstname'] . ' '. $this->data['Application']['lastname'] . '.'; ?>
	<br /><br />If you need to modify a recommendation, make sure "Update this Recommendation" is checked. 
</p>

<?php 
	if (!empty($this->data['Reference'])) {
		if (!is_array($this->data['Reference'])) {
			$this->data['Reference'] = array($this->data['Reference']);
		}
		
		foreach ($this->data['Reference'] as $line => $ref) {
			
			echo "<fieldset><legend>Recommendation submitted by {$ref['firstname']} {$ref['lastname']}</legend>\n";
			echo "<p> Reference Last Modified on: {$ref['modified']}<br />Current Recommendation Filename:";
			echo $this->Html->link($ref['file_name'], array(
															'controller' => 'References', 
															'action' => 'viewLetter',
															$ref['id'],
															$ref['uid'])); 
			echo "<br />Reference Complete: ";
			echo ($ref['complete'])? 'Yes</p>': 'no</p>';
			echo $this->Form->input('Reference.'. $line.".update", array('type' => 'checkbox', 
						'label' => 'Update Recommendation', 'class' => 'checkbox'));
			echo $this->Form->input( $line.".id", array('value' => $ref['id'], 'type' => 'hidden'));
			echo $this->Form->input($line.".uid", array('value' => $ref['uid'], 'type' => 'hidden'));
			echo $this->Form->input($line.".content", array(
																		'label' => 'Upload Reference Letter', 
																		'type' => 'file'));	
			echo $this->Form->input($line.'.complete', array('type' => 'checkbox', 
						'label' => 'This recommendation is complete', 'class' => 'checkbox'));
			echo '</fieldset>';
		} //end foreach reference.
		echo $this->Form->end('Save');
	} else {//end if Ref exists.
		echo '<p> This application has no references. </p>';
	}
?>

